#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
    Module Documentation
    here
"""

# Created by  : Zhang Chengdong
# Create Date : 2024/11/26 11:31 

__author__ = "Zhang Chengdong"
__copyright__ = "Copyright 2024. Large scale model"
__credits__ = ['Zhang Chengdong']

__liscence__ = "MIT"
__version__ = "1.0.1"
__maintainer__ = "Zhang Chengdong"
__status__ = "Production"

import os

from django.conf import settings
# import sys
# sys.path.append(settings.BASE_DIR)
from redis_django_celery.main import app

@app.task(name="linear_train")
def linear_train_async(mas_model_type: str, filtered_data: list):
    from new_model_server.views import linear_train_part
    """
    线形模型训练任务
    """
    linear_train_part(mas_model_type, filtered_data)
    return {"status": "success", "message": "线模型训练完成！", "info":{}}


@app.task(name="nonlinear_train")
def nonlinear_train_async(filtered_data: list, model_name: str, mas_model_type: str):
    """
    非线形模型训练任务
    """
    from new_model_server.views import nonlinear_train_part
    model3_n1d, model3_1d, model28_n1d, model28_1d, model28_3d = nonlinear_train_part(filtered_data,
                         model_name="CatBoost",
                         mas_model_type=mas_model_type)
    return {"status": "success", "info":{
        "预测3天模型（无1天特征）mse与r2": model3_n1d,
        "预测3天模型（1天特征）mse与r2": model3_1d,
        "预测28天模型（无1天特征）mse与r2": model28_n1d,
        "预测28天模型（1天特征）mse与r2": model28_1d,
        "预测28天模型（3天特征）mse与r2": model28_3d
    }}
